#!usr/bin/env python  
#@time: 2018/01/23 
#协程 模型 理解
def consumer():
    r = ''
    while True:
        n = yield r
        if not n:
            return
        print('[CONSUMER] Consuming %s....' %n)
        r = '200 Ok!'

def produce(c):
    c.send(None)
    n = 0
    while n < 5:
        n = n+1
        print('[PRODUCER] producing %s...' %n)
        res = c.send(n)
        print('[PRODUCER] Consumer return: %s' %res)
    c.close()

c = consumer()
produce(c)